//
//  ZYCTeaAttendanceStatisticsOvertimeCell.m
//  ZDSC
//
//  Created by 张威 on 2021/10/22.
//

#import "ZYCTeaAttendanceStatisticsOvertimeCell.h"
#import "ZYCAttendanceStatusGroupView.h"
#import "ZYCTeaLeaveStatisticsModel.h"


@interface ZYCTeaAttendanceStatisticsOvertimeCell ()

@property (nonatomic, strong) UILabel *titleLabel;
@property (nonatomic, strong) UILabel *line;
//休息日加班
@property (nonatomic, strong) ZYCAttendanceStatusGroupView *offDayGroupView;
//节假日加班
@property (nonatomic, strong) ZYCAttendanceStatusGroupView *holidaysGroupView;


@end

@implementation ZYCTeaAttendanceStatisticsOvertimeCell

- (void)setModel:(ZYCTeaLeaveStatisticsModel *)model{
    _model = model;
    _offDayGroupView.count = model.restWork;
    _holidaysGroupView.count = model.holidaysWork;
}

- (void)setHeader:(NSString *)header{
    _header = header;
    _titleLabel.text = header;
}


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self.contentView addSubview:self.titleLabel];
        [self.contentView addSubview:self.line];
        [self.contentView addSubview:self.offDayGroupView];
        [self.contentView addSubview:self.holidaysGroupView];
        
        [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.contentView).offset(19.0f);
            make.top.equalTo(self.contentView).offset(20.0f);
        }];
        
        [self.line mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.equalTo(self.contentView);
            make.top.equalTo(self.titleLabel.mas_bottom).offset(17.0f);
            make.height.mas_equalTo(1);
        }];
        
        CGFloat margin  = (kScreenWidth  - 50 * 4) / 5;
        
        [self.offDayGroupView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.size.mas_equalTo(CGSizeMake(50, 70));
            make.left.equalTo(self.contentView).offset(margin);
            make.top.equalTo(self.line.mas_bottom).offset(20.0f);
        }];
        
        [self.holidaysGroupView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.size.mas_equalTo(CGSizeMake(50, 70));
            make.left.equalTo(self.offDayGroupView.mas_right).offset(margin);
            make.centerY.equalTo(self.offDayGroupView);
        }];
        
    }
    return self;
}
- (ZYCAttendanceStatusGroupView *)offDayGroupView {
    if (!_offDayGroupView) {
        _offDayGroupView = [[ZYCAttendanceStatusGroupView alloc] init];
        _offDayGroupView.color = HEX_RGB(@"#39B5A0");
        _offDayGroupView.title = @"休息日加班";
    }
    return _offDayGroupView;
}

- (ZYCAttendanceStatusGroupView *)holidaysGroupView {
    if (!_holidaysGroupView) {
        _holidaysGroupView = [[ZYCAttendanceStatusGroupView alloc] init];
        _holidaysGroupView.color = HEX_RGB(@"#F05850");
        _holidaysGroupView.title = @"节假日加班";
    }
    return _holidaysGroupView;
}

- (UILabel *)titleLabel {
    if (!_titleLabel) {
        _titleLabel = [UILabel LabelWithFont:kSystemBoldFont(17.0f) titleColor:HEX_RGB(@"#2B302D") textAlignment:ZZTextAlignmentLeft];
    }
    return _titleLabel;
}

- (UILabel *)line {
    if (!_line) {
        _line = [[UILabel alloc] init];
        _line.backgroundColor = HEX_RGB(@"#FAFAFA");
    }
    return _line;
}


@end
